package cn.edu.fudan.tools;

import java.util.ArrayList;
import java.util.List;

import cn.edu.fudan.type.DataItem;

public class BurstAnalysis {
	public void analyzeBusrtInterval(List<DataItem> burst, long threshold_window, int N){
		int[] segment_count = new int[N];
		long segment_time = threshold_window/N;
		
		List<Long> interval = new ArrayList<>();
		long previous_time = burst.get(0).getTimestamp();
		for(int i = 1; i < burst.size(); i ++){
			long time_interval = burst.get(i).getTimestamp() - previous_time;
			interval.add(time_interval);
			
			int num = (int) (time_interval/segment_time); 
			segment_count[num >= N? N-1:num] ++;
			
			previous_time = burst.get(i).getTimestamp();
		}
		System.out.println("["+(segment_time*(0))+","+(segment_time*1)+")\t"+segment_count[0]);
		for(int i = 1; i < N-1; i ++){
			System.out.println("["+(segment_time*(i-1))+","+(segment_time*i)+")\t"+segment_count[i]);
		}
		System.out.println("["+(segment_time*(N-1))+", - )\t"+segment_count[N-1]);
	}
}
